#include <iostream>
using namespace std;

int main() {
    int hourA,hourB;
    int isUnHappy = 0; // 是否不高兴 1-不高兴，0-高兴
    int hourList[7];
    for (int i = 1; i <= 7; i++)
    {
        cin >> hourA >> hourB;
        hourList[i] = hourA + hourB;
        if (hourA + hourB > 8)
        {
            isUnHappy = 1;
        }
    }
    if(isUnHappy == 0) {
        cout << 0;
        return 0;
    }

    // 输出最不高兴的是周几
    int maxUnHappyHour;
    int maxUnHappyDay;
    for (int i = 1; i <= 7; i++)
    {
        if (hourList[i] > 8 && hourList[i] > maxUnHappyHour) {
            maxUnHappyHour = hourList[i];
            maxUnHappyDay = i;
        }
    }
    cout << maxUnHappyDay;
    
    return 0;
}